package cn.tedu.store.controller;

import cn.tedu.store.entity.Product;
import cn.tedu.store.service.IProductService;
import cn.tedu.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品模块的控制器类
 */
@RestController //@Controller+@ResponseBody
@RequestMapping("/products")
public class ProductController extends BaseController{
    @Autowired
    private IProductService productService;

    @RequestMapping("/hot_list")
    public JsonResult<List<Product>> getHotList(){
        List<Product> data = productService.getHotList();
        return new JsonResult<>(OK,data);
    }
    @RequestMapping("/getProduct")
    public JsonResult<Product> getProduct(Integer id){
        Product data = productService.getProduct(id);
        return new JsonResult<>(OK,data);
    }
}

